/**
 * The MIT License (MIT)
 *
 * Copyright © 2017-2020 Ruben Van Boxem
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 **/

/*
 * Native window abstract interface.
 */

#ifndef SKUI_GUI_NATIVE_WINDOW_H
#define SKUI_GUI_NATIVE_WINDOW_H

#include "gui/native_visual.h++"
#include "gui/window_flags.h++"

#include <core/string.h++>

#include <graphics/position.h++>
#include <graphics/size.h++>

#include <memory>

namespace skui::gui::native_window
{
  class base;

  std::unique_ptr<base> create(const graphics::pixel_position& position,
                               const graphics::pixel_size& size,
                               const window_flags& flags);

  class base
  {
  public:
    base(std::unique_ptr<native_visual::base> native_visual);
    virtual ~base() = 0;

    virtual void create(const graphics::pixel_position& initial_position,
                        const graphics::pixel_size& initial_size) = 0;

    virtual void show() = 0;
    virtual void hide() = 0;
    virtual void close() = 0;

    virtual core::string get_title() const = 0;
    virtual void set_title(const core::string& title) = 0;
    virtual std::pair<graphics::pixel_position, graphics::pixel_size> get_current_geometry() const = 0;

    void make_current() const;
    void swap_buffers(const graphics::pixel_size& size);

    native_visual::base& get_native_visual();
    const native_visual::base& get_native_visual() const;

  protected:
    std::unique_ptr<native_visual::base> native_visual;
  };
}

#endif
